/**
 * 
 */
package com.java.test.messagecenter.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * @author 消息推送
 *
 */
public class PushMessageInfo implements RowMapper<PushMessageInfo> {

	// 主键id
	private int id;

	// 推送类型
	private String pushType;

	// 标题
	private String title;

	// 内容
	private String content;

	// 推送条件类型 （用户列表2，画像1）
	private int pushitemType;

	private String pushitemContent;

	// 推送时间
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	private LocalDateTime pushTime;

	private String pushItemAccount;//推送人账号

	public String getPushItemAccount() {
		return pushItemAccount;
	}

	public void setPushItemAccount(String pushItemAccount) {
		this.pushItemAccount = pushItemAccount;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getPushType() {
		return pushType;
	}

	public void setPushType(String pushType) {
		this.pushType = pushType;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public int getPushitemType() {
		return pushitemType;
	}

	public void setPushitemType(int pushitemType) {
		this.pushitemType = pushitemType;
	}

	public String getPushitemContent() {
		return pushitemContent;
	}

	public void setPushitemContent(String pushitemContent) {
		this.pushitemContent = pushitemContent;
	}

	public LocalDateTime getPushTime() {
		return pushTime;
	}

	public void setPushTime(LocalDateTime pushTime) {
		this.pushTime = pushTime;
	}

	@Override
	public PushMessageInfo mapRow(ResultSet rs, int rowNum) throws SQLException {

		PushMessageInfo info = new PushMessageInfo();
		info.setId(rs.getInt("id"));
		info.setContent(rs.getString("content"));
		info.setPushitemContent(rs.getString("pushitem_content"));
		info.setPushitemType(rs.getInt("pushitem_type"));
		info.setPushTime(rs.getTimestamp("push_time") == null ? null
				: rs.getTimestamp("push_time").toInstant().atZone(ZoneOffset.ofHours(8)).toLocalDateTime());
		info.setPushType(rs.getString("push_type"));
		info.setTitle(rs.getString("titile"));
		info.setPushItemAccount(rs.getString("pushitem_account"));
		return info;
	}

}
